package com.stone.boot.pipeline.infra.constant;

import org.springframework.core.io.ClassPathResource;
import org.springframework.scripting.support.ResourceScriptSource;

/**
 * 流水线核心常量
 *
 * @author Mr_wenpan@163.com 2021/08/04 17:29
 */
public interface StonePipelineConstant {

    interface PipelineStrategy {
        String SUCCESS = "SUCCESS";
        String FAILED = "FAILED";
        String END = "END";
        String LOV_CODE = "O2PL.PIPELINE_STRATEGY";
    }

    interface ErrorMessage {
        String PIPELINE_CODE_NULL = "current pipeline code is NULL";
        String PIPELINE_NULL = "current pipeline[%s] is NULL";
        String PIPELINE_EXEC_PARAM_NULL = "current pipeline[%s] parameters is NULL";
        String PIPELINE_START_ACTION_NULL = "current pipeline[%s] start_action is NULL";
        String PIPELINE_NODE_OUT_RANGE = "pipeline[%s] node[%s, %s], the next_action[%s] not in current pipeline";
        String PIPELINE_NODE_CLOSED_LOOP = "pipeline[%s] node[%s, %s], the next_action[%s] is owner closed loop";
        String PIPELINE_START_NODE_NOT_MATCH = "current pipeline[%s] start_action[%s] cannot match all nodes of this pipeline";
    }

    interface Redis {
        String PIPELINE_KEY = "stone:pipeline:%s";
        String PIPELINE_NODE_INFO = "info";
        String PIPELINE_VERSION = "pipeline_version";
        long EXPIRE_TIME_MINUTES = 3;
        ResourceScriptSource PIPELINE_CONF_UPDATE_LUA =
                new ResourceScriptSource(new ClassPathResource("script/lua/pipeline_conf_update.lua"));
    }
}
